﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using V5_Model;

namespace V5_EShop
{
    public partial class ClearItem : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var ItemList = (List<BuyerItem>)Session["BuyerItemList"];
            var user = (V5_Model.ModelGZUser)Session["isLogin"];
            var id = Request.Form["ID"] + string.Empty;


            if (user == null)
            {
                WriteMsg("请先登录！");
            }
            if (id == "")
            {
                WriteMsg("没有你需要删除的信息");
            }

            if (id == "-1")
            {
                ItemList = null;
            }
            else
            {
                var s = id.Split('|');

                foreach (var item in s)
                {
                    if (item == "")
                        continue;
                    ItemList = ItemList.Where(t => t.gid.ToString().ToLower().Trim() != item.ToLower().Trim()).ToList();
                }

            }

            Session["BuyerItemList"] = ItemList;

            WriteMsg("0");

        }

        private void WriteMsg(string info)
        {
            Response.Write(info);
            Response.End();
        }
    }
}